<template>
  <div>
    <el-carousel :interval="4000" type="card" height="500px">
      <el-carousel-item>
        <el-image src="http://139.196.243.68/app/img/lxc/p1.png"></el-image>
      </el-carousel-item>
      <el-carousel-item>
        <el-image src="http://139.196.243.68/app/img/lxc/p2.png"></el-image>
      </el-carousel-item>
      <el-carousel-item>
        <el-image src="http://139.196.243.68/app/img/lxc/p3.png"></el-image>
      </el-carousel-item>
      <el-carousel-item>
        <el-image src="http://139.196.243.68/app/img/lxc/p4.png"></el-image>
      </el-carousel-item>
    </el-carousel>
    <el-row>
      <div style="text-align: center; font-size: 125px; font-style: italic">
        基础课程
      </div>
    </el-row>
    <el-row>
      <el-col
        :span="4"
        v-for="(o, index) in resourceData"
        :key="o"
        :offset="index > 0 ? 0 : 0"
      >
        <el-card :body-style="{ padding: '10px', margin: '40px' }">
          <img :src="o.img" class="image" />
          <div>
            <span>{{ o.name }}</span>
            <div class="bottom clearfix">
              <time class="time">{{ o.date }}</time>
              <el-button type="text" class="button" @click="join()"
                >学习</el-button
              >
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <el-row>
      <h1 style="text-align:center;font-size:50px;color:red">
         基础课程
    </h1>
    </el-row>
    <el-row>
      <el-col
        :span="4"
        v-for="(o, index) in resourceData"
        :key="o"
        :offset="index > 0 ? 0 : 0"
      >
        <el-card :body-style="{ padding: '10px', margin: '40px' }">
          <img :src="o.img" class="image" />
          <div>
            <span>{{ o.name }}</span>
            <div class="bottom clearfix">
              <time class="time">{{ o.date }}</time>
              <el-button type="text" class="button" @click="join()"
                >学习</el-button
              >
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<style>
.font-style {
  background: linear-gradient(to top, #ffba31, #ffd392, #fdf7ee);

  color: transparent;
}
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}

.time {
  font-size: 13px;
  color: #999;
}

.bottom {
  margin-top: 13px;
  line-height: 12px;
}

.button {
  padding: 0;
  float: right;
}

.image {
  width: 100%;
  display: block;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}

.clearfix:after {
  clear: both;
}
</style>

<script>
import { findAll } from "@/api/getResourceData.js";
export default {
  data() {
    return {
      resourceData: [],
      currentDate: new Date(),
    };
  },
  methods: {
    async findAll() {
      const result = await findAll();
      console.log(result.data.data);
      this.resourceData = result.data.data;
    },
    join() {
      // this.$notify({
      //   title: 'tips',
      //   message: '暂无相关资源',
      //   offset: 100
      // });
      console.log("join");
      this.$router.push({ name: "ResourceDetails" });
    },
  },
  created() {
    this.findAll();
  },
};
</script>